package com.sundi.ecgeneralize.config;

import com.sundi.ecgeneralize.config.FileService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;

@Controller
@CrossOrigin
public class FileUpdate {


    @PostMapping("fileUpdate")
    @ResponseBody
    public String fileUpdate( @RequestParam("file") MultipartFile file) throws IOException {
        //上传默认文件大小是1M
        //可以早配置文件修改上传文件的大小
        String fileName=file.getOriginalFilename();
        System.out.println(file+"-----"+fileName);
        File file2=new File("D:/pic2"+File.separator+fileName);
        file.transferTo(file2);
        return fileName;
    }


    @RequestMapping("/downLoad")
    public String downLoad(HttpServletResponse response, HttpServletRequest request) {

        FileService.downLoad(response, request);
        return null;
    }







}
